/**
 *
 */
import Util;
import OpenApi;

import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('pam', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model CreateAssetCredentialRequest {
  regionId?: string(name='RegionId'),
  instanceId?: string(name='InstanceId'),
  assetUuid?: string(name='AssetUuid'),
  assetThirdId?: string(name='AssetThirdId'),
  assetRegionId?: string(name='AssetRegionId'),
  assetType?: string(name='AssetType'),
  credentialType?: string(name='CredentialType'),
  accountName?: string(name='AccountName'),
  password?: string(name='Password'),
  privateKey?: string(name='PrivateKey'),
  passPhrase?: string(name='PassPhrase'),
  description?: string(name='Description'),
}

model CreateAssetCredentialResponseBody = {
  requestId?: string(name='RequestId'),
  credentialName?: string(name='CredentialName'),
}

model CreateAssetCredentialResponse = {
  headers: map[string]string(name='headers'),
  body: CreateAssetCredentialResponseBody(name='body'),
}

async function createAssetCredentialWithOptions(request: CreateAssetCredentialRequest, runtime: Util.RuntimeOptions): CreateAssetCredentialResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('CreateAssetCredential', '2020-09-30', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function createAssetCredential(request: CreateAssetCredentialRequest): CreateAssetCredentialResponse {
  var runtime = new Util.RuntimeOptions{};
  return createAssetCredentialWithOptions(request, runtime);
}

model CreateInstanceRequest {
  regionId?: string(name='RegionId'),
}

model CreateInstanceResponseBody = {
  requestId?: string(name='RequestId'),
  instanceAttribute?: {
    instanceId?: string(name='InstanceId'),
  }(name='InstanceAttribute'),
}

model CreateInstanceResponse = {
  headers: map[string]string(name='headers'),
  body: CreateInstanceResponseBody(name='body'),
}

async function createInstanceWithOptions(request: CreateInstanceRequest, runtime: Util.RuntimeOptions): CreateInstanceResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('CreateInstance', '2020-09-30', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function createInstance(request: CreateInstanceRequest): CreateInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return createInstanceWithOptions(request, runtime);
}

model DescribeAuditLogsRequest {
  regionId?: string(name='RegionId'),
  instanceId?: string(name='InstanceId'),
  sessionId?: string(name='SessionId'),
  operatorUid?: string(name='OperatorUid'),
  protocolType?: string(name='ProtocolType'),
  assetThirdId?: string(name='AssetThirdId'),
  assetRegionId?: string(name='AssetRegionId'),
  accountName?: string(name='AccountName'),
  clientSourceIp?: string(name='ClientSourceIp'),
  pageNumber?: int32(name='PageNumber'),
  pageSize?: int32(name='PageSize'),
}

model DescribeAuditLogsResponseBody = {
  totalCount?: long(name='TotalCount'),
  requestId?: string(name='RequestId'),
  auditLogs?: [ 
    {
      operatorUid?: string(name='OperatorUid'),
      userType?: string(name='UserType'),
      assetThirdId?: string(name='AssetThirdId'),
      sessionRegionId?: string(name='SessionRegionId'),
      eventTime?: long(name='EventTime'),
      assetName?: string(name='AssetName'),
      instanceId?: string(name='InstanceId'),
      clientSourceIp?: string(name='ClientSourceIp'),
      assetType?: string(name='AssetType'),
      assetRegionId?: string(name='AssetRegionId'),
      assetPort?: string(name='AssetPort'),
      eventType?: string(name='EventType'),
      protocolType?: string(name='ProtocolType'),
      sessionId?: string(name='SessionId'),
      content?: string(name='Content'),
      assetIp?: string(name='AssetIp'),
      accountName?: string(name='AccountName'),
    }
  ](name='AuditLogs'),
}

model DescribeAuditLogsResponse = {
  headers: map[string]string(name='headers'),
  body: DescribeAuditLogsResponseBody(name='body'),
}

async function describeAuditLogsWithOptions(request: DescribeAuditLogsRequest, runtime: Util.RuntimeOptions): DescribeAuditLogsResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('DescribeAuditLogs', '2020-09-30', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function describeAuditLogs(request: DescribeAuditLogsRequest): DescribeAuditLogsResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeAuditLogsWithOptions(request, runtime);
}

model DescribeInstancesRequest {
  regionId?: string(name='RegionId'),
  instanceId?: string(name='InstanceId'),
  pageNumber?: int32(name='PageNumber'),
  pageSize?: int32(name='PageSize'),
}

model DescribeInstancesResponseBody = {
  instances?: [ 
    {
      idaasInstanceId?: string(name='IdaasInstanceId'),
      portalHomeUrl?: string(name='PortalHomeUrl'),
      assetInitStatus?: string(name='AssetInitStatus'),
      licenseInfo?: {
        maxRegisteredAsset?: long(name='MaxRegisteredAsset'),
        maxSingleAssetCredential?: long(name='MaxSingleAssetCredential'),
        maxConcurrentSession?: long(name='MaxConcurrentSession'),
        currentRegisteredAsset?: long(name='CurrentRegisteredAsset'),
      }(name='LicenseInfo'),
      instanceId?: string(name='InstanceId'),
      idaasRegionId?: string(name='IdaasRegionId'),
      appInitStatus?: string(name='AppInitStatus'),
    }
  ](name='Instances'),
  totalCount?: int32(name='TotalCount'),
  requestId?: string(name='RequestId'),
}

model DescribeInstancesResponse = {
  headers: map[string]string(name='headers'),
  body: DescribeInstancesResponseBody(name='body'),
}

async function describeInstancesWithOptions(request: DescribeInstancesRequest, runtime: Util.RuntimeOptions): DescribeInstancesResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('DescribeInstances', '2020-09-30', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function describeInstances(request: DescribeInstancesRequest): DescribeInstancesResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeInstancesWithOptions(request, runtime);
}

model DescribeRegionsRequest {
  regionId?: string(name='RegionId'),
  acceptLanguage?: string(name='AcceptLanguage'),
}

model DescribeRegionsResponseBody = {
  requestId?: string(name='RequestId'),
  regions?: [ 
    {
      localName?: string(name='LocalName'),
      regionEndpoint?: string(name='RegionEndpoint'),
      regionId?: string(name='RegionId'),
    }
  ](name='Regions'),
}

model DescribeRegionsResponse = {
  headers: map[string]string(name='headers'),
  body: DescribeRegionsResponseBody(name='body'),
}

async function describeRegionsWithOptions(request: DescribeRegionsRequest, runtime: Util.RuntimeOptions): DescribeRegionsResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('DescribeRegions', '2020-09-30', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function describeRegions(request: DescribeRegionsRequest): DescribeRegionsResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeRegionsWithOptions(request, runtime);
}

model DescribeSessionsRequest {
  regionId?: string(name='RegionId'),
  instanceId?: string(name='InstanceId'),
  operatorUid?: string(name='OperatorUid'),
  sessionId?: string(name='SessionId'),
  sessionStatus?: string(name='SessionStatus'),
  assetThirdId?: string(name='AssetThirdId'),
  assetRegionId?: string(name='AssetRegionId'),
  pageNumber?: int32(name='PageNumber'),
  pageSize?: int32(name='PageSize'),
}

model DescribeSessionsResponseBody = {
  totalCount?: long(name='TotalCount'),
  requestId?: string(name='RequestId'),
  sessions?: [ 
    {
      endTime?: long(name='EndTime'),
      operatorUid?: string(name='OperatorUid'),
      startTime?: long(name='StartTime'),
      sessionStatus?: string(name='SessionStatus'),
      userType?: string(name='UserType'),
      assetThirdId?: string(name='AssetThirdId'),
      sessionType?: string(name='SessionType'),
      protocolType?: string(name='ProtocolType'),
      sessionId?: string(name='SessionId'),
      accountName?: string(name='AccountName'),
      assetRegionId?: string(name='AssetRegionId'),
    }
  ](name='Sessions'),
}

model DescribeSessionsResponse = {
  headers: map[string]string(name='headers'),
  body: DescribeSessionsResponseBody(name='body'),
}

async function describeSessionsWithOptions(request: DescribeSessionsRequest, runtime: Util.RuntimeOptions): DescribeSessionsResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('DescribeSessions', '2020-09-30', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function describeSessions(request: DescribeSessionsRequest): DescribeSessionsResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeSessionsWithOptions(request, runtime);
}

model GenerateDirectOperationTokenRequest {
  regionId?: string(name='RegionId'),
  instanceId?: string(name='InstanceId'),
  assetUuid?: string(name='AssetUuid'),
  protocolType?: string(name='ProtocolType'),
  credentialName?: string(name='CredentialName'),
  accountName?: string(name='AccountName'),
  password?: string(name='Password'),
  privateKey?: string(name='PrivateKey'),
  passPhrase?: string(name='PassPhrase'),
}

model GenerateDirectOperationTokenResponseBody = {
  requestId?: string(name='RequestId'),
  token?: string(name='Token'),
}

model GenerateDirectOperationTokenResponse = {
  headers: map[string]string(name='headers'),
  body: GenerateDirectOperationTokenResponseBody(name='body'),
}

async function generateDirectOperationTokenWithOptions(request: GenerateDirectOperationTokenRequest, runtime: Util.RuntimeOptions): GenerateDirectOperationTokenResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('GenerateDirectOperationToken', '2020-09-30', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function generateDirectOperationToken(request: GenerateDirectOperationTokenRequest): GenerateDirectOperationTokenResponse {
  var runtime = new Util.RuntimeOptions{};
  return generateDirectOperationTokenWithOptions(request, runtime);
}

model GeneratePlaybackTokenRequest {
  regionId?: string(name='RegionId'),
  instanceId?: string(name='InstanceId'),
  sessionId?: string(name='SessionId'),
}

model GeneratePlaybackTokenResponseBody = {
  requestId?: string(name='RequestId'),
  playbackToken?: string(name='PlaybackToken'),
}

model GeneratePlaybackTokenResponse = {
  headers: map[string]string(name='headers'),
  body: GeneratePlaybackTokenResponseBody(name='body'),
}

async function generatePlaybackTokenWithOptions(request: GeneratePlaybackTokenRequest, runtime: Util.RuntimeOptions): GeneratePlaybackTokenResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('GeneratePlaybackToken', '2020-09-30', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function generatePlaybackToken(request: GeneratePlaybackTokenRequest): GeneratePlaybackTokenResponse {
  var runtime = new Util.RuntimeOptions{};
  return generatePlaybackTokenWithOptions(request, runtime);
}

model GetAssetDetailRequest {
  regionId?: string(name='RegionId'),
  instanceId?: string(name='InstanceId'),
  assetUuid?: string(name='AssetUuid'),
  assetThirdId?: string(name='AssetThirdId'),
  assetRegionId?: string(name='AssetRegionId'),
  assetType?: string(name='AssetType'),
}

model GetAssetDetailResponseBody = {
  requestId?: string(name='RequestId'),
  assetDetail?: {
    assetThirdId?: string(name='AssetThirdId'),
    assetUuid?: string(name='AssetUuid'),
    assetCredentialInfos?: [ 
      {
        credentialName?: string(name='CredentialName'),
        description?: string(name='Description'),
        credentialType?: string(name='CredentialType'),
      }
    ](name='AssetCredentialInfos'),
    assetSource?: string(name='AssetSource'),
    registeredStatus?: string(name='RegisteredStatus'),
    assetProtocolInfos?: [ 
      {
        protocolType?: string(name='ProtocolType'),
        port?: int32(name='Port'),
      }
    ](name='AssetProtocolInfos'),
    assetType?: string(name='AssetType'),
    assetRegionId?: string(name='AssetRegionId'),
    assetRunningStatus?: string(name='AssetRunningStatus'),
    assetFingerprint?: string(name='AssetFingerprint'),
    assetAddressInfos?: [ 
      {
        addressIPVersion?: string(name='AddressIPVersion'),
        ipAddress?: string(name='IpAddress'),
        addressType?: string(name='AddressType'),
      }
    ](name='AssetAddressInfos'),
    description?: string(name='Description'),
    assetGroupName?: string(name='AssetGroupName'),
    supportedRegister?: boolean(name='SupportedRegister'),
  }(name='AssetDetail'),
}

model GetAssetDetailResponse = {
  headers: map[string]string(name='headers'),
  body: GetAssetDetailResponseBody(name='body'),
}

async function getAssetDetailWithOptions(request: GetAssetDetailRequest, runtime: Util.RuntimeOptions): GetAssetDetailResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('GetAssetDetail', '2020-09-30', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function getAssetDetail(request: GetAssetDetailRequest): GetAssetDetailResponse {
  var runtime = new Util.RuntimeOptions{};
  return getAssetDetailWithOptions(request, runtime);
}

model ModifyAssetsPortRequest {
  regionId?: string(name='RegionId'),
  instanceId?: string(name='InstanceId'),
  assetProtocol?: string(name='AssetProtocol'),
  assetPort?: int32(name='AssetPort'),
  assetUuids?: [ string ](name='AssetUuids'),
}

model ModifyAssetsPortResponseBody = {
  requestId?: string(name='RequestId'),
}

model ModifyAssetsPortResponse = {
  headers: map[string]string(name='headers'),
  body: ModifyAssetsPortResponseBody(name='body'),
}

async function modifyAssetsPortWithOptions(request: ModifyAssetsPortRequest, runtime: Util.RuntimeOptions): ModifyAssetsPortResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('ModifyAssetsPort', '2020-09-30', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function modifyAssetsPort(request: ModifyAssetsPortRequest): ModifyAssetsPortResponse {
  var runtime = new Util.RuntimeOptions{};
  return modifyAssetsPortWithOptions(request, runtime);
}

model RegisterAssetRequest {
  regionId?: string(name='RegionId'),
  instanceId?: string(name='InstanceId'),
  assetUuid?: string(name='AssetUuid'),
  assetThirdId?: string(name='AssetThirdId'),
  assetRegionId?: string(name='AssetRegionId'),
  assetType?: string(name='AssetType'),
}

model RegisterAssetResponseBody = {
  requestId?: string(name='RequestId'),
}

model RegisterAssetResponse = {
  headers: map[string]string(name='headers'),
  body: RegisterAssetResponseBody(name='body'),
}

async function registerAssetWithOptions(request: RegisterAssetRequest, runtime: Util.RuntimeOptions): RegisterAssetResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('RegisterAsset', '2020-09-30', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function registerAsset(request: RegisterAssetRequest): RegisterAssetResponse {
  var runtime = new Util.RuntimeOptions{};
  return registerAssetWithOptions(request, runtime);
}

